package com.yyq.statistics.schedule;

import com.yyq.statistics.controller.DailyController;
import com.yyq.statistics.utils.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @author yyq
 * @create 2021-05-10 13:30
 */
@Component
public class Schedule {
    @Autowired
    DailyController controller;

//    @Test
//    @Scheduled(cron = "0/5 * * * * ?")
//    public void test(){
//        System.out.println("1111");
//
//    }
    //每天凌晨一点自动执行更新前一天统计数据
    @Scheduled(cron = "0 0 1 * * ? ")
    public void updateData(){
        String day = DateUtil.formatDate(DateUtil.addDays(new Date(), -1));
        controller.getStatisticsData(day);

    }


}
